<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\DB;

class DelayOrder implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
    protected $data;
    protected  $key = 'order_list';

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct($data = [])
    {
        $this->data = $data;
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {

        $data = $this->data;

        //
        $results = DB::select('select * from mall_order where id = :id', [$data['id']]);
var_dump($data);
        if($results[0]->status == 1){
            $affected = DB::update('update mall_order set status = 0 where id = ?', [$data['id']]);
            if($affected){
                var_dump('success');
            }
        }else{
            return;
        }

    }
}
